#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>

using namespace std;

const int N = 2e5 + 10;

int n;
int arr[N];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i];
    int left = 0;
    int ret = 1;
    while (left < n)
    {
        int right = left;
        while (right + 1 < n && arr[right + 1] - arr[right] <= 8) right++;
        ret = max(ret, right - left + 1);
        left = right + 1;
    }
    cout << ret << endl;
    return 0;
}